package TakeAwaySystem.businessoperation;

import TakeAwaySystem.Business;
import TakeAwaySystem.User;

import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * @author Vv
 * @version 1.0
 * @project coding_learn
 * @description
 * @date 2023/9/25 22:32:13
 */
public interface BusinessIOperatition {
    public void work(Business o, File file);
    public void ListToFile(List<User> list,File file);
//        File file = new File("d:elm_v1/Business.txt");
//        FileWriter fileWriter = null;
//        BufferedWriter bw = null;
//        try {
//            fileWriter = new FileWriter(file);
//            bw = new BufferedWriter(fileWriter);
//            for(int i = 0;i<list.size();i++){
//                BusinessMng bus = list.get(i);
//                StringBuilder sbr = new StringBuilder();
//                sbr.append(bus.getBusinessId() + " ");
//                sbr.append(bus.getPassword() + " ");
//                sbr.append(bus.getBusinessName() + " ");
//                sbr.append(bus.getBuinessAddress() + " ");
//                sbr.append(getBusinessExplain() + " ");
//                sbr.append(getStarPrices() + " ");
//                sbr.append(getDeliveryPrice() + " ");
//
//                bw.write(sbr.toString());
//                bw.newLine();
//            }
//        } catch (IOException e) {
//            throw new RuntimeException(e);
//        }finally {
//            bw.close();
//            fileWriter.close();
//        }


    public  List<User> fileToList(File file) throws IOException;
    //        List<BusinessMng> list = new ArrayList<>();
//        File file = new File("d:/elm_v1/Business.txt");
//        FileReader fr = new FileReader(file);
//        BufferedReader br = new BufferedReader(fr);
//        while(true){
//            String str = br.readLine();
//            if(str != null){
//                String[] arr = str.split(" ");
//                BusinessMng business = new BusinessMng();
//                business.setBusinessId(Integer.valueOf(arr[0]));
//                business.setPassword(arr[1]);
//                business.setBusinessName(arr[2]);
//                business.setBuinessAddress(arr[3]);
//                business.setBusinessExplain(arr[4]);
//                business.setStarPrices(Double.valueOf(arr[5]));
//                business.setDeliveryPrice(Double.valueOf(arr[6]));
//                list.add(business);
//            }else {
//                break;
//            }
//        }
//        return list;


   // void work(User user, File file);
}
